﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditUser.aspx.cs" Inherits="Skyworth.CRM.Web.SystemManagement.EditUser" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>销售管理平台 | 修改用户</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <%--[if IE]>
     <link href="../themes/css/ieHack.css" rel="stylesheet" type="text/css" />
    <![endif]--%>
    <script src="../javascripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <link href="../themes/silver/style.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/core.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/pages.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/wbox.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/Messagebox.css" rel="stylesheet" type="text/css" />
    <script src="../javascripts/jquery.autocomplete.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txtEmpId").autocomplete("../Service/EmployeeHandler.ashx", {
                minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                formatItem: function (result, i, max) {
                    var item = "<span>" + result[1] + "(" + result[2] + ")</span>"
                    return item;
                },
                //extraParams: { CustId: 0 },
                formatResult: function (row) { return row[1]; }
            });
            $("#txtEmpId").result(function (event, data, formatted) {
                if (data && data.length > 0) {
                    $("#hitIndividualId").val(data[0]);
                }
            });

            $("#txtCustId").autocomplete("../Service/CustomerHandler.ashx", {
                minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                formatItem: function (result, i, max) {
                    var item = "<span>" + result[1] + "</span>"
                    return item;
                },
                //extraParams: { CustId: 0 },
                formatResult: function (row) { return row[1]; }
            });
            $("#txtCustId").result(function (event, data, formatted) {
                if (data && data.length > 0) {
                    $("#hitIndividualId").val(data[0]);
                }
            });
            if ($("#ddlstUserType").val() == "1") {
                $("#lblUser").html("内部员工：");
                $("#txtEmpId").css("display", "block");
                $("#txtCustId").css("display", "none");        
            }
            else {
                $("#lblUser").html("客户：");
                $("#txtEmpId").css("display", "none");
                $("#txtCustId").css("display", "block");       
            }
        })

        $(function () {
            $("#ddlstUserType").change(function () {
                return ChangeData();
            })

            $("#btnOk").click(function () {
                return SavaCheck();
            })
            $("#btnClose").click(function () {
                parent.addWindow.close();
                //parent.location.reload();
            })
        })
        function ChangeData() {
            var txtUserType = $("#ddlstUserType").val();            
            if (txtUserType == "1") {
                $("#lblUser").html("内部员工：");
                $("#txtEmpId").css("display", "block");
                $("#txtCustId").css("display", "none");                
            }
            else {
                $("#lblUser").html("客户：");
                $("#txtEmpId").css("display", "none");
                $("#txtCustId").css("display", "block");                
            }
        }
        function SavaCheck() {
            var temp = $("#hitIndividualId").val();
            var txtIndiv = $("#hitIndividualId").val();
            var txtUserName = $("#txtUserName");
            var txtUserType = $("#ddlstUserType").val();
            var UserName = txtUserName.val();
            if (UserName == "" || UserName.length <= 0) {
                $("#txtMsg").text("请输入用户名称！");
                $("#txtMsg").fadeIn();
                txtUserName.focus();
                return false;
            }
            if (txtUserType == "1") {
                if (txtIndiv == "" || txtIndiv.length <= 0) {
                    $("#txtMsg").text("请输入员工！");
                    $("#txtMsg").fadeIn();
                    return false;
                }
            }
            else {
                if (txtIndiv == "" || txtIndiv.length <= 0) {
                    $("#txtMsg").text("请输入客户！");
                    $("#txtMsg").fadeIn();
                    return false;
                }
            }

            if ($("#chklRole input:checked").length <= 0) {
                $("#txtMsg").text("请设置用户角色！");
                $("#txtMsg").fadeIn();
                return false;
            }

            if ($("#txtPassword").val() == "" || $("#txtPassword").val().length<=0) {
                $("#txtMsg").text("请设置用户密码！");
                $("#txtMsg").fadeIn();
                return false;
            }
        }
    </script>
    
    <style type="text/css">
        html
        {
            overflow-x: hidden;
        }
        table
        {
        	  border-collapse: collapse;
              border-spacing: 0;
              table-layout: fixed;
              width  : 100%;
              border: solid 1px #AAA;
        }
        table tr td
        {
        	 border-bottom: solid 1px #AAA;
        	 padding:0px 3px;
        	 background-color: #EFEFEF;       	 
        	 
        }
        td label
        {       	
        	 padding:2px 2px;
        }
        td.left
        {        	
        	border-right: solid 1px #AAA;
        	width: 70px;
        }  
        td.right
        {
        	background:#FFF;
        }
        td.right,td.readOnly
        {          
          padding:5px 3px;
        } 
       
        .txt
        {
        	  border: 1px solid #C3C3C3;
            color: #333333;
            font-family: Arial,Verdana,Helvetica,sans-serif;
            height: 20px;
            line-height: 20px;
            width:290px;
        }    
       .red
       {
       	color:Red; font-weight :bold;
       }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <table>
            <tr>
                <td class="left">
                    <label>用户名称：<em class="red">*</em></label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtUserName" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="left">
                    <label>用户类别：<em class="red">*</em></label>
                </td>
                <td class="right">
                    <asp:DropDownList ID="ddlstUserType" runat="server">
                        <asp:ListItem Value="2">客户</asp:ListItem>
                        <asp:ListItem Value="1">内部员工</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="left"><asp:Label ID="lblUser" Text="客户：" runat="server"></asp:Label><em class="red">*</em></td>
                <td class="right">
                    <input ID="txtCustId" type="text" runat="server" class="txt" />
                    <input ID="txtEmpId" style="display: none;" type="text" runat="server" class="txt" />
                    <input type="hidden" style="display: none;" id="hitIndividualId" runat="server" />
                    
                </td>
            </tr>
            <tr>
                <td class="left">
                    <label>所属角色：<em class="red">*</em></label>
                </td>
                <td class="right">                    
                    <asp:CheckBoxList ID="chklRole" runat="server" DataTextField="RoleName" DataValueField="RoleID" RepeatColumns="3" RepeatLayout="Flow">
                    </asp:CheckBoxList>
                    
                </td>
            </tr>
            <tr>
                <td class="left">
                    <label>邮件地址：</label>
                </td>
                <td class="right">
                     <asp:TextBox ID="txtEmail" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="left">
                    <label>密码：<em class="red">*</em></label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtPassword" CssClass="txt" runat="server" MaxLength="100" 
                        TextMode="Password"></asp:TextBox>
                </td>
            </tr>                     
            <tr>
                <td colspan="2" class="readOnly" style="padding-right:12px; background:url('../themes/silver/images/grid/grid.png') repeat scroll 0 0">                    
                    <a title="关闭该页面" href="javascript:void(0)" class="button" style="float:left" id="btnClose"><span>关闭</span></a>
                     <span style="padding:5px;display:none; width:150px;float:left" class="red" id="txtMsg"></span>                   
                    <div class="buttonActive" style="float:right">
                        <div class="buttonContent" >
                            <asp:Button ID="btnOk" runat="server" Text="确定"  CssClass="serverButton" 
                                onclick="btnOk_Click" />
                         </div>
                    </div>
                </td>
            </tr>
        </table>
    
    </form>
</body>
</html>
